<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./axios.min.js"></script>
    <script src="./vue.global.prod.js"></script>
</head>

<body>
    <div id="app">
        <input type="text" v-model="movieId">
        <button @click="doFilmOne">film/movie</button>
        <br>
        <img style="width: 200px" :src="coverUrl" alt="">
    </div>
    <script>
        //设置 全局请求地址
        axios.defaults.baseURL = 'http://10.0.6.157:8000/fc';
        //设置 POST请求的默认Content-Type
        axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
        //设置全局的 请求拦截
        axios.interceptors.request.use(function (config) {
            // 携带 token
            console.log(config);
            config.headers.token = 't'+Date.now();//模拟token
            return config;
        }, function (error) {
            return Promise.reject(error);
        });

        // http://10.0.6.157:8000/fc
        // /film/findByPage
        // /film/movie
        Vue.createApp({
            data() {
                return {
                    coverUrl: '',
                    movieId: '36328210',
                }
            },
            methods: {
                async doFilmOne() {
                    try {
                        const response = await axios.get('/film/movie/' + this.movieId);
                        //服务器响应的数据
                        console.log('data:', response.data);
                        this.coverUrl = response.data.data.cover_url;
                    } catch (error) {
                        console.log('error:', error);
                    }
                }
            },
        }).mount('#app');

    </script>
</body>

</html>